
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
null</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?key=67f19b2653d068ffd5fd2bf6ddd1149d&v=1.2&services=true">
</script>
</head>
<body>
<input type="hidden" id="first">
<input type="hidden" id="last">
<input type="hidden" id="addr0">
<input type="hidden" id="addr1">
<input type="hidden" id="addr2">
<input type="hidden" id="addr3">
<input type="hidden" id="addr4">
<input type="hidden" id="addr5">
<input type="hidden" id="addr6">
<input type="hidden" id="addr7">
<input type="hidden" id="addr8">
<input type="hidden" id="addr9">
<div style="width:100%;height:100%;" id="container">
</div>
<div id="log" style="font-size:13px;margin-top:0px;display:none;">
</div>
</body>
</html>
<script type="text/javascript">

//form.submit();


var map = new BMap.Map("container");
map.setCurrentCity("广州市");
map.centerAndZoom(new BMap.Point(113.32, 23.15), 13);
//var opts = {type: BMAP_NAVIGATION_CONTROL_ZOOM, offset: new BMap.Size(50, 50)}
//map.addControl(new BMap.NavigationControl(opts));

//window.qml.qmlCall();

var myGeo = new BMap.Geocoder();

var options = { 
  renderOptions: {map: map,autoViewport: true},
  onSearchComplete: function(results){
    if (transit.getStatus() == BMAP_STATUS_SUCCESS){
      // 获取第一条方案
      var plan = results.getPlan(0);

      //for (i = 0; i < plan.getNumLines(); i ++){
	//  var line = plan.getLine(i);
	//  map.addOverlay(new BMap.Polyline(line.getPoints()));
      //}

      // 获取方案的公交线路
    var s = [];
    for (i = 0; i < results.getNumPlans(); i ++){
      s.push((i + 1) + ". " + results.getPlan(i).getDescription());
    }
    document.getElementById("log").innerHTML = s.join("<br/>");
window.qml.searchsuccess();
    //document.getElementById("log").innerHTML = results.toString() ;
    window.qml.route = document.getElementById("log").innerHTML;
    }
  }
};
var transit = new BMap.TransitRoute(map,options);
//var transit = new BMap.TransitRoute(map);
// transit.setSearchCompleteCallback(function(results)
// {
//   //alert("1");
//   if (transit.getStatus() == BMAP_STATUS_SUCCESS){
//     window.qml.searchsuccess();
//     //alert("get route successful!");
//     //window.qml.qmlCall();
//     //form.submit();
//     var firstPlan = results.getPlan(0);
//     // 绘制步行线路
//     for (var i = 0; i < firstPlan.getNumRoutes(); i ++){
//       var walk = firstPlan.getRoute(i);
//       if (walk.getDistance(false) > 0){
//         // 步行线路有可能为0
// 	//window.qml.searchsuccess();
//         map.addOverlay(new BMap.Polyline(walk.getPoints(), {lineColor: "green"}));
//       }
//     }
// window.qml.searchsuccess();
//     // 绘制公交线路
//     for (i = 0; i < firstPlan.getNumLines(); i ++){
//       var line = firstPlan.getLine(i);
//       alert(line.getNumViaStops());
//       var arry = line.getPoints();
// window.qml.searchsuccess();
//       var poly = new BMap.Polyline(arry);
//       //map.addOverlay(new BMap.Polyline(line.getPoints()));
//       map.addOverlay(poly);
//       //window.qml.searchsuccess();
//     }
// window.qml.searchsuccess();
//     // 输出方案信息
//     var s = [];
//     for (i = 0; i < results.getNumPlans(); i ++){
//       s.push((i + 1) + ". " + results.getPlan(i).getDescription());
//     }
//     document.getElementById("log").innerHTML = s.join("<br/>");
// window.qml.searchsuccess();
//     //document.getElementById("log").innerHTML = results.toString() ;
//     window.qml.route = document.getElementById("log").innerHTML;
//     //form.route = s.toString();
//     //alert(s.join("\n"));
//     //alert("fuck!");
//     //form.submit();
//   }
// })


var firstt = document.getElementById("first").value 
var lastt = document.getElementById("last").value
//transit.search("五山", "体育中心");
//alert(firstt);
//transit.search(firstt, lastt);


var options = {
  onSearchComplete: function(results){
    if (local.getStatus() == BMAP_STATUS_SUCCESS){
      // 判断状态是否正确
      //var s = [];
      for (var i = 0; i < results.getCurrentNumPois(); i ++){
	document.getElementById("addr" + i).value = (results.getPoi(i).title + ", " + results.getPoi(i).address);
	//window.qml.addr.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
        //s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
      }
      //document.getElementById("log").innerHTML = s.join("<br/>");

      window.qml.addr0 = document.getElementById("addr0").value;
      window.qml.addr1 = document.getElementById("addr1").value;
      window.qml.addr2 = document.getElementById("addr2").value;
      window.qml.addr3 = document.getElementById("addr3").value;
      window.qml.addr4 = document.getElementById("addr4").value;
      window.qml.addr5 = document.getElementById("addr5").value;
      window.qml.addr6 = document.getElementById("addr6").value;
      window.qml.addr7 = document.getElementById("addr7").value;
      window.qml.addr8 = document.getElementById("addr8").value;
      window.qml.addr9 = document.getElementById("addr9").value;

      window.qml.qmlCall();

    }
  }
};
var local = new BMap.LocalSearch(map, options);
//local.search("五山");

</script>

